home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d20 / pvert.arc / STRIPS.C < prev    next >
C/C++ Source or Header  |  1992-01-15  |  862b  |  53 lines

  1. #include <string.h>
  2. #include <ctype.h>
  3.  
  4.  
  5.  
  6. char * rstrip (char *a) {   /* Remove trailing spaces and tabs */
  7.  
  8.   register int x;
  9.  
  10.  
  11.   x = strlen(a);
  12.   while(x && (a[x - 1] == ' ' || a[x - 1] == '\t')) a[--x] = 0;
  13.   return a;
  14. }
  15.  
  16.  
  17.  
  18.  
  19. char * lstrip (char *a) {   /* Remove leading spaces and tabs */
  20.  
  21.   register char *p = a;
  22.  
  23.  
  24.   while(*p == ' ' || *p == '\t') p++;
  25.   if(*p && p > a) memmove(a,p,strlen(p) + 1);
  26.   else if(!*p) *a = 0;
  27.   return a;
  28. }
  29.  
  30.  
  31.  
  32. char * stripcr (char *a) {  /* Remove trailing crs and lfs */
  33.  
  34.   register int x;
  35.  
  36.  
  37.   x = strlen(a);
  38.   while(x && (a[x - 1] == '\n' || a[x - 1] == '\r')) a[--x] = 0;
  39.   return a;
  40. }
  41.  
  42.  
  43.  
  44. char * strip_trail_bksl (char *a) {  /* Remove trailing slashes */
  45.  
  46.   register int x;
  47.  
  48.  
  49.   x = strlen(a);
  50.   while (x && (a[x - 1] == '/' || a[x - 1] == '\\')) a[--x] = 0;
  51.   return a;
  52. }
  53.